using System.Drawing;
using TouchSmart.Gestures;

namespace TouchSmart.Widgets
{
    public abstract class Widget
    {
        public Point Location { get; set; }
        public Size Size { get; set; }
        public bool IsSelected { get; set; }

        public Rectangle Bounds
        {
            get { return new Rectangle(Location.X, Location.Y, Size.Width, Size.Height); }
        }

        protected Widget() : this(new Point(), new Size()) { }

        protected Widget(Point location, Size size)
        {
            Location = location;
            Size = size;
        }

        public abstract void Draw(Graphics g);

        public bool HitTest(Point point)
        {
            return Bounds.Contains(point);
        }

        public virtual void OnClick(ClickEventArgs e) { }

        public virtual void OnMovement(MovementEventArgs e) { }

        public virtual void OnMouseUp(ClickEventArgs e)
        {
            IsSelected = false;
        }

        public virtual void OnMouseDown(ClickEventArgs e)
        {
            IsSelected = HitTest(e.Location);
        }

        public virtual void OnSlide(SlideEventArgs e) { }
    }
}